﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Test30.Core;

namespace Test30.Tools.DataView
{
    public partial class UserControl2 : UserControl
    {
        public UserControl2()
        {
            InitializeComponent();

            Location = new Point(100, 100);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }

        public void Setmap()
        {

            Refresh();
        }

        public override void Refresh()
        {
            Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {

            e.Graphics.ScaleTransform(1.0F, -1.0F);
            e.Graphics.TranslateTransform(0.0F, -(float)Height);

            //            if (MapHandler != null)
            //            {
            //                for (int x = 0; x < MapHandler.MapWidth; x++)
            //                {
            //                    for (int y = 0; y < MapHandler.MapHeight; y++)
            //                    {
            //                        Rectangle rect = new Rectangle(x * TileSize, y * TileSize, TileSize, TileSize);
            //                        if (e.ClipRectangle.IntersectsWith(rect))
            //                        {
            //                            Brush brush = Brushes.DarkBlue;
            //                            if (MapHandler.Map[x, y].Type == Engine.TileType.Wall) brush = Brushes.DarkGray;
            //                            if (MapHandler.Map[x, y].Type == Engine.TileType.StairsUp) brush = Brushes.OrangeRed;
            //                            if (MapHandler.Map[x, y].Type == Engine.TileType.StairsDown) brush = Brushes.DeepSkyBlue;
            //
            //                            e.Graphics.FillRectangle(brush, rect);
            //                            e.Graphics.DrawRectangle(Line, rect);
            //                        }
            //                    }
            //                }
            //            }

            Rectangle rectangle = new Rectangle(0, 0, 200, 1);

            e.Graphics.FillRectangle(Brushes.Beige, rectangle);
        }
        private static readonly Pen Line = new Pen(Color.Beige,5);
        private const int TileSize = 20;


    }

}
